package jy.game.components.item;


import java.util.ArrayList;
import java.util.List;

import wx.xml.simpleframework.xml.Attribute;
import wx.xml.simpleframework.xml.Element;
import wx.xml.simpleframework.xml.ElementList;
import wx.xml.simpleframework.xml.Root;

@Root(name = "trigger")
public class JyItemTrigger {
    static String[] attributes = {
        "生命上限",
        "内力上限",
        "搏击格斗",
        "使剑技巧",
        "耍刀技巧",
        "奇门兵器",
        "根骨",
        "臂力",
        "福缘",
        "身法",
        "定力",
        "悟性"
    };

    //        public JyTrigger GenerateItemTrigger(int itemLevel) {
//            // FileLogger.instance.Log("JyITTrigger.cs:25 %s %s", this.name, itemLevel);
//            JyTrigger trigger = new JyTrigger(this.name);
//            int round = RuntimeData.Instance.round;
//            if (this.name == "attribute") {
//
//                int randomInt;
//                if (CommonSettings.MOD_KEY == 1) {
//                    randomInt = Tools.getRandomInt(0, attributes.length - 1);
//                } else {
//                    randomInt = Tools.getRandomInt(0, attributes.length - 1);
//                }
//                //if (randomInt > 1) {
//                //    String attribute = attributes[randomInt];
//                //    int min = (int)((double)itemLevel * ((double)(round + 3) / 4.0)) + itemLevel * 2;
//                //    int max = (int)((double)itemLevel * ((double)(round + 3) / 3.0)) + itemLevel * 4;
//                //    trigger.argvsValue = String.format("%s,%s", attribute, Tools.getRandomInt(min, max));
//                //    // FileLogger.instance.Log("JyITTrigger.cs:42");
//                //    return trigger;
//                //}
//                //if (CommonSettings.MOD_KEY == -1) {
//                //    String arg2 = attributes[randomInt];
//                //    int a2 = (int)((double)itemLevel * ((double)(round + 3) * 33.0)) + itemLevel * 100;
//                //    int b2 = (int)((double)itemLevel * ((double)(round + 3) * 50.0)) + itemLevel * 150;
//                //    trigger.argvsValue = String.format("%s,%s", arg2, Tools.getRandomInt(a2, b2));
//                //    // FileLogger.instance.Log("JyITTrigger.cs:50");
//                //    return trigger;
//                //}
//                String attribute = attributes[randomInt];
//                int min = (int)(itemLevel * ((round + 3) * 100.0)) + itemLevel * 1000;
//                int max = (int)(itemLevel * ((round + 3) * 150.0)) + itemLevel * 1500;
//                trigger.argvsValue = String.format("%s,%s", attribute, Tools.getRandomInt(min, max));
//                // FileLogger.instance.Log("JyITTrigger.cs:57");
//                return trigger;
//            }
//            if (CommonSettings.MOD_KEY == 1) {
//                // FileLogger.instance.Log("JyITTrigger.cs:62");
//                JyTrigger result = generateTrigger1(itemLevel, round, ref trigger);
//                if (result != null) {
//                    // FileLogger.instance.Log("JyITTrigger.cs:65");
//                    return result;
//                }
//            } else {
//                // FileLogger.instance.Log("JyITTrigger.cs:69");
//                JyTrigger result = generateTrigger0(itemLevel, round, ref trigger);
//                if (result != null) {
//                    // FileLogger.instance.Log("JyITTrigger.cs:72");
//                    return result;
//                }
//            }
//
//            switch (this.name) {
//                case "attack":
//                    int a12 = itemLevel * 2 * (1 + round * 2);
//                    int b4 = itemLevel * 3 * (1 + round * 2) + Tools.getRandomInt(1, round * 2);
//                    trigger.argvsValue = String.format("%s,%s", Tools.getRandomInt(a12, b4), Tools.getRandomInt(itemLevel, 15));
//                    // FileLogger.instance.Log("JyITTrigger.cs:181");
//                    return trigger;
//                case "defence":
//                    int a13 = itemLevel * (1 + round * 2);
//                    int b5 = itemLevel * 3 * (1 + round * 2) + Tools.getRandomInt(0, round);
//                    trigger.argvsValue = String.format("%s,%s", Tools.getRandomInt(a13, b5), Tools.getRandomInt(1, itemLevel));
//                    // FileLogger.instance.Log("JyITTrigger.cs:187");
//                    return trigger;
//                case "powerup_quanzhang":
//                case "powerup_qimen":
//                case "powerup_daofa":
//                case "powerup_jianfa":
//                case "powerup_xianshu":
//                    int a14 = (int)(itemLevel * 0.4 * (1.0 + round * 1.3));
//                    int b6 = (int)(itemLevel * 0.6 * (1.0 + round * 1.3));
//                    trigger.argvsValue = String.format("%s", Tools.getRandomInt(a14, b6));
//                    // FileLogger.instance.Log("JyITTrigger.cs:194");
//                    return trigger;
//                case "criticalp":
//                    double num9 = 15f;
//                    double num10 = itemLevel;
//                    trigger.argvsValue = Math.round(Tools.getRandom(num9, num10), 2).toString();
//                    // FileLogger.instance.Log("JyITTrigger.cs:199");
//                    return trigger;
//                default:
//                    // FileLogger.instance.Log("JyITTrigger.cs:202");
//                    break;
//            }
//
//            List<String> list = new ArrayList<String>();
//            list.Clear();
//            // FileLogger.instance.Log("JyITTrigger.cs:109");
//            for (int i = 0; i < this.Params.Count; i++) {
//                JyItemParam itparam = this.Params[i];
//                if (itparam.Min != -1) {
//                    list.add(Tools.getRandomInt(itparam.Min, itparam.Max).toString());
//                } else if (itparam.Pool != "") {
//                    String[] array2 = itparam.Pool.split(new char[] { ',' });
//                    String item = array2[Tools.getRandomInt(0, array2.Length - 1)];
//                    list.add(item);
//                }
//            }
//            // FileLogger.instance.Log("JyITTrigger.cs:218");
//            trigger.argvsValue = "";
//            for (int j = 0; j < list.Count; j++) {
//                JyTrigger trigger2 = trigger;
//                trigger2.argvsValue = trigger2.argvsValue + list[j] + ",";
//            }
//            trigger.argvsValue.TrimEnd(new char[] { ',' });
//            // FileLogger.instance.Log("JyITTrigger.cs:225");
//            return trigger;
//        }
//        private JyTrigger generateTrigger0(int itemLevel, int round, ref JyTrigger trigger) {
//            switch (this.name) {
//                case "powerup_skill":
//                    JySkill random5 = Tools.GetRandomElement<JySkill>(JyResourceManager.GetAllAsList<JySkill>(),
//                    item => { return item.hard - itemLevel; }, t => { return 1.0; });
//                    //do {
//                    //    random5 = JyResourceManager.getRandom<JySkill>();
//                    //} while (itemLevel + 4 < random5.hard || random5.hard + 1f < itemLevel);
//                    int a8 = (int)(10f * ((round + 3) / (double)(random5.hard / 2.0 + 1.0)));
//                    int num5 = (int)(15f * ((round + 3) / (double)(random5.hard / 2.0 + 1.0)));
//                    if (random5.hard < 6f) {
//                        num5 += round * 15;
//                    }
//                    trigger.argvsValue = String.format("%s,%s", random5.name, Tools.getRandomInt(a8, num5));
//                    // FileLogger.instance.Log("JyITTrigger.cs:130");
//                    return trigger;
//                case "powerup_internalskill":
//                    internalSkill random6 = Tools.GetRandomElement<internalSkill>(JyResourceManager.GetAllAsList<internalSkill>(),
//                    item => { return item.hard - itemLevel; }, t => { return 1.0; }); ;
//                    //do {
//                    //    random6 = JyResourceManager.getRandom<internalSkill>();
//                    //} while (itemLevel + 4 < random6.hard || random6.hard + 1f < itemLevel);
//                    int a9 = (int)(7f * ((round + 3) / (double)(random6.hard / 2.0 + 1.0)));
//                    int num6 = (int)(10f * ((round + 3) / (double)(random6.hard / 2.0 + 1.0)));
//                    if (random6.hard < 6f) {
//                        num6 += round * 10;
//                    }
//                    trigger.argvsValue = String.format("%s,%s", random6.name, Tools.getRandomInt(a9, num6));
//                    // FileLogger.instance.Log("JyITTrigger.cs:143");
//                    return trigger;
//                case "powerup_aoyi":
//                    JyAoyi randomAoYi = Tools.GetRandomElement<JyAoyi>(JyResourceManager.GetAllAsList<JyAoyi>(),
//                    item => { return item.GetStartSkillHard() - itemLevel; }, t => { return 1.0; }); ;
//                    double startSkillHard2 = randomAoYi.GetStartSkillHard();
//                    //do {
//                    //    random7 = JyResourceManager.getRandom<JyAoyi>();
//                    //    startSkillHard2 = random7.GetStartSkillHard();
//                    //} while (itemLevel + 4 < startSkillHard2 || startSkillHard2 + 1f < itemLevel);
//                    int a10 = (int)(21f * ((round + 3) / (double)(startSkillHard2 / 2.0 + 1.0)));
//                    int num7 = (int)(30f * ((round + 3) / (double)(startSkillHard2 / 2.0 + 1.0)));
//                    if (startSkillHard2 < 6f) {
//                        num7 += round * 15;
//                    }
//                    trigger.argvsValue = String.format("%s,%s,%s", randomAoYi.name, Tools.getRandomInt(a10, num7), Tools.getRandomInt(10, 20));
//                    // FileLogger.instance.Log("JyITTrigger.cs:158");
//                    return trigger;
//                case "powerup_uniqueskill":
//                    JyUniqueSkill randomUniqueSkill = Tools.GetRandomElement<JyUniqueSkill>(JyResourceManager.GetAllAsList<JyUniqueSkill>(),
//                    item => { return item.hard - itemLevel; }, t => { return 1.0; });
//                    //do {
//                    //    random8 = JyResourceManager.getRandom<JyUniqueSkill>();
//                    //} while (itemLevel + 4 < random8.hard || random8.hard + 1f < itemLevel);
//                    int a11 = (int)(18f * ((round + 3) / (double)(randomUniqueSkill.hard / 2.0 + 1.0)));
//                    int num8 = (int)(25f * ((round + 3) / (double)(randomUniqueSkill.hard / 2.0 + 1.0)));
//                    if (randomUniqueSkill.hard < 6f) {
//                        num8 += round * 15;
//                    }
//                    trigger.argvsValue = String.format("%s,%s", randomUniqueSkill.name, Tools.getRandomInt(a11, num8));
//                    // FileLogger.instance.Log("JyITTrigger.cs:171");
//                    return trigger;
//                default:
//                    // FileLogger.instance.Log("JyITTrigger.cs:174");
//                    break;
//            }
//
//            return null;
//        }
//        private JyTrigger generateTrigger1(int itemLevel, int round, ref JyTrigger trigger) {
//            switch (this.name) {
//                case "powerup_skill":
//                    JySkill random = Tools.GetRandomElement<JySkill>(JyResourceManager.GetAllAsList<JySkill>(),
//                    delegate (JySkill item) {
//                        return item.hard - itemLevel;
//
//                    }, delegate {
//                        return 1.0;
//
//                    });
//                    //do {
//                    //    random = JyResourceManager.getRandom<JySkill>();
//                    //} while (itemLevel + 5 < random.hard || random.hard + 1f < itemLevel);
//                    int a4 = (int)(12f * ((round + 3) / (double)(random.hard / 2.0 + 1.0)));
//                    int num = (int)(15f * ((round + 3) / (double)(random.hard / 2.0 + 1.0)));
//                    if (random.hard < 4f) {
//                        num += round * 15;
//                    }
//                    trigger.argvsValue = String.format("%s,%s", random.name, Tools.getRandomInt(a4, num));
//                    // FileLogger.instance.Log("JyITTrigger.cs:72");
//                    return trigger;
//                case "powerup_internalskill":
//                    internalSkill random2 = Tools.GetRandomElement<internalSkill>(JyResourceManager.GetAllAsList<internalSkill>(),
//                    item => { return item.hard - itemLevel; }, t => { return 1.0; });
//                    //do {
//                    //    random2 = JyResourceManager.getRandom<internalSkill>();
//                    //} while (itemLevel + 4 < random2.hard || random2.hard + 1f < itemLevel);
//                    int a5 = (int)(7f * ((round + 3) / (double)(random2.hard / 2.0 + 1.0)));
//                    int num2 = (int)(10f * ((round + 3) / (double)(random2.hard / 2.0 + 1.0)));
//                    if (random2.hard < 6f) {
//                        num2 += round * 10;
//                    }
//                    trigger.argvsValue = String.format("%s,%s", random2.name, Tools.getRandomInt(a5, num2));
//                    // FileLogger.instance.Log("JyITTrigger.cs:85");
//                    return trigger;
//                case "powerup_aoyi":
//                    JyAoyi random3 = Tools.GetRandomElement<JyAoyi>(JyResourceManager.GetAllAsList<JyAoyi>(),
//                    item => { return item.GetStartSkillHard() - itemLevel; }, t => { return 1.0; });
//                    double startSkillHard = random3.GetStartSkillHard();
//                    //do {
//                    //    random3 = JyResourceManager.getRandom<JyAoyi>();
//                    //    startSkillHard = random3.GetStartSkillHard();
//                    //} while (itemLevel + 5 < startSkillHard || startSkillHard + 1f < itemLevel);
//                    int a6 = (int)(22f * ((round + 3) / (double)(startSkillHard / 2.0 + 1.0)));
//                    int num3 = (int)(26f * ((round + 3) / (double)(startSkillHard / 2.0 + 1.0)));
//                    if (startSkillHard < 6f) {
//                        num3 += round * 15;
//                    }
//                    trigger.argvsValue = String.format("%s,%s,%s", random3.name, Tools.getRandomInt(a6, num3), Tools.getRandomInt(5, 10));
//                    // FileLogger.instance.Log("JyITTrigger.cs:100");
//                    return trigger;
//                case "powerup_uniqueskill":
//                    JyUniqueSkill random4 = Tools.GetRandomElement<JyUniqueSkill>(JyResourceManager.GetAllAsList<JyUniqueSkill>(),
//                    item => { return item.hard - itemLevel; }, t => { return 1.0; });
//                    //do {
//                    //    random4 = JyResourceManager.getRandom<JyUniqueSkill>();
//                    //} while (itemLevel + 5 < random4.hard || random4.hard + 1f < itemLevel);
//                    int a7 = (int)(22f * ((round + 3) / (double)(random4.hard / 2.0 + 1.0)));
//                    int num4 = (int)(26f * ((round + 3) / (double)(random4.hard / 2.0 + 1.0)));
//                    if (random4.hard < 6f) {
//                        num4 += round * 15;
//                    }
//                    trigger.argvsValue = String.format("%s,%s", random4.name, Tools.getRandomInt(a7, num4));
//                    // FileLogger.instance.Log("JyITTrigger.cs:113");
//                    return trigger;
//                default:
//                    // FileLogger.instance.Log("JyITTrigger.cs:116");
//                    break;
//            }
//
//            return null;
//        }
    @Attribute(name = "name")  public String            Name   = "";
    @Attribute(name = "w")  public int               Weight = 100;
    @ElementList(name = "param", inline = true) public List<JyItemParam> Params = new ArrayList<>();
    // [XmlIgnore]
    public int               itemTriggerMaxLevel;

    // (get) Token: 0x06000423 RID: 1059 RVA: 0x0002D59C File Offset: 0x0002B79C
    public boolean HasPool() {
        {
            for (JyItemParam itparam : this.Params) {
                if (itparam.Pool != "") {
                    return true;
                }
            }
            return false;
        }
    }
}